//
//  LGDiseaseMedicineChartCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/10/16.
//

#import "LGDiseaseMedicineChartCell.h"
#import "LGMedicineRecordChart.h"

@interface LGDiseaseMedicineChartCell()<LGMedicineRecordChartDelegate>
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)LGMedicineRecordChart *chartView;

/**  是否需要*/
@property (nonatomic , assign)BOOL needData;

@end

@implementation LGDiseaseMedicineChartCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setMedicineid:(NSString *)medicineid{
    _medicineid = medicineid;
    self.chartView.medicineid = medicineid;
}

-(void)setMedicineArray:(NSArray *)medicineArray{
    _medicineArray = medicineArray;
    if(self.chartView.medicArray != medicineArray)
    self.chartView.medicArray = medicineArray;
}

-(void)setChartDic:(NSDictionary *)chartDic{
    _chartDic = chartDic;
    self.chartView.dataDic = chartDic;
}

-(void)requestChartData:(NSString *)medicinId{
    if(self.delegate && [self.delegate respondsToSelector:@selector(requestChartDataAction:)]){
        [self.delegate requestChartDataAction:medicinId];
    }
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.clipsToBounds = YES;
    self.backgroundColor = [UIColor clearColor];
    self.contentView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.baseView];
    [self.contentView addSubview:self.chartView];
    [self.baseView addSubview:self.titleLabel];
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(viewPix(16));
        make.right.equalTo(self.contentView).offset(-viewPix(16));
        make.top.bottom.equalTo(self.contentView);
        make.height.equalTo(@(viewPix(385)));
    }];
}

-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B2BDC7" offset:CGSizeMake(0, 2) opacity:0.15 radius:0];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"患者记录" colorString:@"#333333" textFont:LGFontWeight(15, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
        _titleLabel.frame = CGRectMake(viewPix(12), viewPix(5), viewPix(150), viewPix(20));
    }
    return _titleLabel;
}

-(LGMedicineRecordChart *)chartView{
    if(!_chartView){
        _chartView = [[LGMedicineRecordChart alloc]initWithFrame:CGRectMake(0, -viewPix(15), Screen_W, viewPix(420))];
        _chartView.title = @"";
        _chartView.delegate = self;
    }
    return _chartView;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
